package com.zmc.product.controller;

import com.zmc.common.domain.query.home.*;
import com.zmc.common.utils.R;
import com.zmc.product.application.HomeApplicationService;
import com.zmc.product.infrastructure.bean.query.BannerQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author：zmc
 * @Date：2024/10/31 9:28
 */


@RestController
@RequestMapping("/home")
public class HomeController {

    @Autowired
    private HomeApplicationService homeApplicationService;


    @PostMapping("/category/head")
    public R head() {
        return R.ok(homeApplicationService.getCategory());
    }

    @PostMapping("/banner")
    public R banner(@RequestBody BannerQuery query) {
        return R.ok(homeApplicationService.getBanners(query.getDistributionSite()));
    }

    /**
     * 首页大屏搜索
     * */
    @PostMapping("/keyword")
    public R homeGoods(@RequestBody HomeKeywordFeignQuery query) {
        return R.ok(homeApplicationService.homeGoods(query));
    }

    /**
     * 按综合搜索
     * */
    @PostMapping("/total")
    public R totalGoods(@RequestBody HomeTotalFeignQuery query) {
        return R.ok(homeApplicationService.totalGoods(query));
    }

    /**
     * 按销量搜索
     * */
    @PostMapping("/sale")
    public R saleCountGoods(@RequestBody HomeSaleCountFeignQuery query) {
        return R.ok(homeApplicationService.saleCountGoods(query));
    }

    /**
     * 按热卖搜索
     * */
    @PostMapping("/hot")
    public R hotGoods(@RequestBody HomeHotFeignQuery query) {
        return R.ok(homeApplicationService.hotGoods(query));
    }

    /**
     * 按价格搜索
     * */
    @PostMapping("/price")
    public R priceGoods(@RequestBody HomeSalePriceFeignQuery query) {
        return R.ok(homeApplicationService.priceGoods(query));
    }

}
